package io.github.lee.core.util

import android.content.Context
import android.content.res.Configuration


fun screenWidth(context: Context): Int {
    val resources = context.resources
    val dm = resources.displayMetrics
    return dm.widthPixels

}

fun screenHeight(context: Context): Int {
    val resources = context.resources
    val dm = resources.displayMetrics
    return dm.heightPixels

}

//较小的宽度 	宽度 < 600dp 	99.96% 的手机处于竖屏模式
//中等宽度 	600dp ≤ 宽度 < 840dp 	93.73% 的平板电脑处于竖屏模式，
//
//最大展开状态的内屏（竖屏模式）
//较大宽度 	宽度 ≥ 840dp
fun screenDensity(context: Context): Float {
    val resources = context.resources
    val dm = resources.displayMetrics
    return dm.density
}

fun smallestWidth(context: Context): Float {
    val density = screenDensity(context)
    val width = screenWidth(context) / density
//    val height  = screenHeight(context) / density
    return width
}

fun isScreenLand(context: Context) =
    context.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
